﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace TicTacToe.Core.Statistics
{
    partial class Database
    {
        public PlayerID GetPlayerById(Guid id)
        {
            return mPlayers.SingleOrDefault(n => n.Id == id);
        }

        public PlayerID GetPlayerByName(string name)
        {
            return mPlayers.SingleOrDefault(n => n.Name == name);
        }

        public GameID GetGameById(Guid id)
        {
            return mGames.SingleOrDefault(n => n.Id == id);
        }

        public IEnumerable<TurnID> GetTurnsForGame(Guid id)
        {
            return mTurns.Where(n => n.Game == id);
        }

        public IEnumerable<GameID> GetGames()
        {
            return mGames;
        }

        public IEnumerable<PlayerID> GetPlayers()
        {
            return mPlayers;
        }

        public IEnumerable<TurnID> GetTurns()
        {
            return mTurns;
        }

        public IEnumerable<KeyValuePair<GameID, PlayerID>> GetGameWinners()
        {
            return mWinners;
        }
    }
}
